GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b7c62f...776483 )
by Florian
01:13
created

Marker.initialize   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 1
c 3
b 1
f 0
nc 1
nop 4
dl 0
loc 36
rs 8.8571

1 Function

Rating   Name   Duplication   Size   Complexity  
A 0 1 1
1
/*jslint
2
  indent: 4
3
*/
4
5
/*global
6
  $, google,
7
  Cookies, Coordinates, IconFactory, Lines,
8
  id2alpha
9
*/
10
11
function Marker(parent, id) {
12
    'use strict';
13
14
    this.m_parent = parent;
15
    this.m_id = id;
16
    this.m_alpha = id2alpha(id);
17
    this.m_free = true;
18
    this.m_name = "";
19
    this.m_color = ["#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#FFFFFF"][id % 7],
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
20
    this.m_iconColor = "";
21
    this.m_iconLabel = "";
22
    this.m_miniIconUrl = "";
23
    this.m_marker = null;
24
    this.m_circle = null;
25
}
26
27
28
Marker.prototype.toString = function () {
29
    'use strict';
30
31
    return this.getAlpha() + ":" + this.getPosition().lat().toFixed(6) + ":" + this.getPosition().lng().toFixed(6) + ":" + this.getRadius() + ":" + this.getName();
32
};
33
34
35
Marker.prototype.toXmlWpt = function () {
36
    'use strict';
37
38
    var data = '';
39
    data += '<wpt lat="' + this.getPosition().lat().toFixed(8) + '" lon="' + this.getPosition().lng().toFixed(8) + '">\n';
40
    data += '    <name>' + this.getName() + '</name>\n';
41
    data += '    <sym>flag</sym>\n';
42
    if (this.getRadius() > 0) {
43
        data += '    <extensions>\n';
44
        data += '      <wptx1:WaypointExtension>\n';
45
        data += '        <wptx1:Proximity>' + this.getRadius() + '</wptx1:Proximity>\n';
46
        data += '      </wptx1:WaypointExtension>\n';
47
        data += '    </extensions>\n';
48
    }
49
    data += '</wpt>';
50
51
    return data;
52
};
53
54
55
Marker.prototype.isFree = function () {
56
    'use strict';
57
58
    return this.m_free;
59
};
60
61
62
Marker.prototype.clear = function () {
63
    'use strict';
64
65
    if (this.m_free) {
66
        return;
67
    }
68
69
    this.m_free = true;
70
    this.m_marker.setMap(null);
71
    this.m_marker = null;
72
    this.m_circle.setMap(null);
73
    this.m_circle = null;
74
    this.m_iconColor = "";
75
    this.m_iconLabel = "";
76
77
    $('#dyn' + this.m_id).remove();
78
79
    Lines.updateLinesMarkerRemoved(this.m_id);
80
    this.m_parent.handleMarkerCleared();
81
};
82
83
84
Marker.prototype.getId = function () {
85
    'use strict';
86
87
    return this.m_id;
88
};
89
90
91
Marker.prototype.getAlpha = function () {
92
    'use strict';
93
94
    return this.m_alpha;
95
};
96
97
98
Marker.prototype.getName = function () {
99
    'use strict';
100
101
    return this.m_name;
102
};
103
104
105
Marker.prototype.setName = function (name) {
106
    'use strict';
107
108
    this.m_name = name;
109
    this.update();
110
};
111
112
113
Marker.prototype.setPosition = function (position) {
114
    'use strict';
115
116
    this.m_marker.setPosition(position);
117
    this.m_circle.setCenter(position);
118
    this.update();
119
};
120
121
122
Marker.prototype.getPosition = function () {
123
    'use strict';
124
125
    return this.m_marker.getPosition();
126
};
127
128
129
Marker.prototype.setRadius = function (radius) {
130
    'use strict';
131
132
    this.m_circle.setRadius(radius);
133
    this.update();
134
};
135
136
137
Marker.prototype.getRadius = function () {
138
    'use strict';
139
140
    return this.m_circle.getRadius();
141
};
142
143
144
Marker.prototype.setNamePositionRadius = function (name, position, radius) {
145
    'use strict';
146
147
    this.m_name = name;
148
    this.m_marker.setPosition(position);
149
    this.m_circle.setCenter(position);
150
    this.m_circle.setRadius(radius);
151
    this.update();
152
};
153
154
155
Marker.prototype.initialize = function (map, name, position, radius) {
156
    'use strict';
157
158
    this.m_free = false;
159
    this.m_name = name;
160
    this.m_iconLabel = name;
161
    this.m_iconColor = this.m_color;
162
163
    var self = this,
164
        color = "#0090ff",
165
        icon = IconFactory.createMapIcon(this.m_name, this.m_color);
166
167
    this.m_miniIconUrl = IconFactory.createMiniIcon(this.m_alpha, this.m_color);
168
169
    this.m_marker = new google.maps.Marker({
170
        position: position,
171
        map: map,
172
        icon: icon,
173
        optimized: false,
174
        draggable: true
175
    });
176
177
    google.maps.event.addListener(this.m_marker, "drag", function () { self.update(); });
178
    google.maps.event.addListener(this.m_marker, "dragend", function () { self.update(); });
179
180
    this.m_circle = new google.maps.Circle({
181
        center: position,
182
        map: map,
183
        strokeColor: color,
184
        strokeOpacity: 1,
185
        fillColor: color,
186
        fillOpacity: 0.25,
187
        strokeWeight: 1,
188
        radius: radius
189
    });
190
};
191
192
193
Marker.prototype.update = function () {
194
    'use strict';
195
196
    if (this.m_free) {
197
        return;
198
    }
199
200
    var pos = this.m_marker.getPosition(),
201
        radius = this.m_circle.getRadius(),
202
        icon;
0 ignored issues
show
Unused Code introduced by
The variable icon seems to be never used. Consider removing it.
Loading history...
203
204
    this.m_circle.setCenter(pos);
205
206
    Cookies.set('marker' + this.m_id, pos.lat().toFixed(6) + ":" + pos.lng().toFixed(6) + ":" + radius + ":" + this.m_name, {expires: 30});
207
    $('#dyn' + this.m_id + ' > .view .name').html(this.m_name);
208
    $('#dyn' + this.m_id + ' > .view .coords').html(Coordinates.toString(pos));
209
    $('#dyn' + this.m_id + ' > .view .radius').html(radius);
210
    $('#dyn' + this.m_id + ' > .edit .name').val(this.m_name);
211
    $('#dyn' + this.m_id + ' > .edit .coords').val(Coordinates.toString(pos));
212
    $('#dyn' + this.m_id + ' > .edit .radius').val(radius);
213
214
    if ((this.m_iconLabel != this.m_name) != (this.m_iconColor != this.m_color)) {
215
        this.m_iconLabel = this.m_name;
216
        this.m_iconColor = this.m_color;
217
        this.m_marker.setIcon(IconFactory.createMapIcon(this.m_name, this.m_color));
218
        this.m_miniIconUrl = IconFactory.createMiniIcon(this.m_alpha, this.m_color);
219
    }
220
    $('#dyn' + this.m_id + ' > .view .icon').attr("src", this.m_miniIconUrl);
221
222
    Lines.updateLinesMarkerMoved(this.m_id);
223
};
224